package pablo.developer;

import android.content.res.Resources;
import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;
import android.widget.Toast;

public class MenuPrincipal extends TabActivity {
	
	String name="",vuelta="";
	int idUser;
	public void onCreate(Bundle savedInstanceState) {
		
		super.onCreate(savedInstanceState);
		setContentView(R.layout.menuprincipal);
		
		
		Bundle bundle  = getIntent().getExtras();
		if (bundle!=null){
			vuelta  = bundle.getString("vuelta");
			idUser  = bundle.getInt("idUser");
			name 	= bundle.getString("name");
		}
		if (!"vengo".equals(vuelta)){
			Toast toast1 =Toast.makeText(getApplicationContext(),"Bienvenido/a "+ name, Toast.LENGTH_LONG);
			toast1.show();
		}
		Resources res = getResources(); 
	    TabHost tabHost = getTabHost(); 
	    TabHost.TabSpec spec;  
	    Intent mainIntent;  
	    
	    // Tab Conductor
	    mainIntent = new Intent().setClass(this, MenuPrincipalConductor.class);
	    bundle     = new Bundle();
	 	bundle.putInt("idUser",idUser);
	 	bundle.putString("name", name);
	 	mainIntent.putExtras(bundle);
	    spec = tabHost.newTabSpec("TAB1").setIndicator("Conductor",
	                      res.getDrawable(R.drawable.ic_input_add))
	                  .setContent(mainIntent);
	    tabHost.addTab(spec);
	    
	 // Tab Pasajero
	    mainIntent = new Intent().setClass(this, MenuPrincipalPasajero.class);
	    bundle     = new Bundle();
	    bundle.putInt("idUser",idUser);
	    bundle.putString("name", name);
	 	mainIntent.putExtras(bundle);
	    spec = tabHost.newTabSpec("TAB2").setIndicator("Pasajero",
	                      res.getDrawable(R.drawable.ic_input_add))
	                  .setContent(mainIntent);
	    tabHost.addTab(spec);
	   
	 // Tab Vehiculo
	    mainIntent = new Intent().setClass(this, NuevoVehiculo.class);
	    bundle     = new Bundle();
	    bundle.putInt("idUser",idUser);
	    bundle.putString("name", name);
	 	mainIntent.putExtras(bundle);
	    spec = tabHost.newTabSpec("TAB3").setIndicator(res.getString(R.string.vehiculo),
	                      res.getDrawable(R.drawable.stat_notify_car_mode))
	                  .setContent(mainIntent);
	    tabHost.addTab(spec);
	    
	 // Tab Ruta
	    mainIntent = new Intent().setClass(this, MenuConsultarRuta.class);
	    bundle     = new Bundle();
	    bundle.putInt("idUser", idUser);
	    bundle.putString("name", name);
	 	mainIntent.putExtras(bundle);
	    spec = tabHost.newTabSpec("TAB4").setIndicator("Ruta",
	                      res.getDrawable(R.drawable.ic_search_category_default))
	                  .setContent(mainIntent);
	    tabHost.addTab(spec);
	    
	    tabHost.setCurrentTab(3);
	}
 }